#include "myhead.h"


//增加ip
void ip_add(const char *newip,int port,int fd,const char *name)
{
    ip *n = malloc(sizeof(ip));
    n->data.fd = fd;
    strncpy(n->data.ip, newip, sizeof(n->data.ip));
    n->data.port = port;
    strncpy(n->data.name, name, sizeof(n->data.name));
    pthread_mutex_lock(&g_list_mtx);
    g_list = n;
    pthread_mutex_unlock(&g_list_mtx);
}

static void list_del(int fd) 
{
    pthread_mutex_lock(&g_list_mtx);
    ip_list **pp = &g_list;
    while (*pp) {
        if ((*pp)->fd == fd) {
            ip_list *tmp = *pp;
            *pp = tmp->next;
            free(tmp);
            break;
        }
        pp = &(*pp)->next;
    }
    flag=0;
    pthread_mutex_unlock(&g_list_mtx);
}
